package ch.cm.adnroid.cleverlearn.model;

import java.util.ArrayList;
import java.util.Random;

import android.util.Pair;

public class Question {

    private static int MAX_AMOUNT_OF_ANSWERS = 3;

    private String question, answer, w_answerA, w_answerB, picName;
    private int id, rACount;
    private boolean yOn;

    public Question(int id, String question, String answer, String w_answerA, String w_answerB, int rACount, boolean yOn) {
        this.id = id;
        this.rACount = rACount;
        this.yOn = yOn;
        this.question = question;
        this.answer = answer;
        this.w_answerA = w_answerA;
        this.w_answerB = w_answerB;
    }

    public Question(int id, String question, String answer, String w_answerA, int rACount, boolean yOn) {
        this.id = id;
        this.yOn = yOn;
        this.rACount = rACount;
        this.answer = answer;
        this.w_answerA = w_answerA;
        this.w_answerB = "Weiss es niiid";
    }

    public ArrayList<Pair<String, Boolean>> getAnswerMap() {
        ArrayList<Pair<String, Boolean>> answerlist = new ArrayList<Pair<String, Boolean>>();
        int desition = new Random().nextInt(MAX_AMOUNT_OF_ANSWERS);
        Pair<String, Boolean> p1 = new Pair<String, Boolean>(answer, true);
        Pair<String, Boolean> p2 = new Pair<String, Boolean>(w_answerA, false);
        Pair<String, Boolean> p3 = new Pair<String, Boolean>(w_answerB, false);
        switch (desition) {
        case 0:
            answerlist.add(p1);
            answerlist.add(p2);
            answerlist.add(p3);
            break;
        case 1:
            answerlist.add(p2);
            answerlist.add(p3);
            answerlist.add(p1);
            break;
        case 2:
            answerlist.add(p3);
            answerlist.add(p1);
            answerlist.add(p2);
            break;

        default:
            answerlist.add(p1);
            answerlist.add(p2);
            answerlist.add(p3);
            break;
        }
        return answerlist;

    }

    public String getAnswer() {
        return answer;
    }

    public String getQuestion() {
        return question;
    }

    public int getId() {
        return id;
    }

    public int getrACount() {
        return rACount;
    }

    public void setrACount(int rACount) {
        this.rACount = rACount;
    }

    public String getPicName() {
        return picName;
    }

    public void setPicName(String picName) {
        this.picName = picName;
    }

    @Override
    public String toString() {
        return "Question: " + question + "\n" + "Answer: " + answer + "\n" + "WAnswer_1: " + w_answerA + "\n"
                + "WAnswer_1: " + w_answerB + "\n" + "WACount: " + rACount + "\n" + "Y_N: " + yOn + "\n";

    }

}
